#!/usr/bin/python -O

from operator import itemgetter
import sys

word2count = {}

for line in sys.stdin:
    word, count = line.strip().split('\t', 1)
    try:
        count = int(count)
        word2count[word] = word2count.get(word,0) + count
    except ValueError:
        pass

for word, count in sorted(word2count.items(), key=itemgetter(0)):
    print '{0}\t{1}'.format(word, count)

